<template>
  <div>
    <h2>虫 害 详 细 信 息</h2>
    <div class="info">
      <div class="left">
        <p>名称：{{ pest.pestName }}</p>
        <p>繁殖：{{ pest.pestBreed }}</p>
        <p>寄主：{{ pest.pestHost }}</p>
        <p>天敌：{{ pest.pestSentinel }}</p>
        <p>主要危害：{{ pest.pestMainHarm }}</p>
        <p>防治措施：{{ pest.pestControl }}</p>
      </div>
      <div class="right">
        <span>幼虫图片</span>
        <img :src="/api/ + pest.pestLarvaPic" alt="未找到" /> <br /><br /><br />
        <span>成虫图片</span>
        <img :src="/api/ + pest.pestAdultPic" alt="未找到" />
      </div>
    </div>
    <el-row>
      <el-button plain @click="back()">返回</el-button>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      pestId: "",
      pest: "",
    };
  },
  methods: {
    async getPestInfo(pestId) {
      let paramObj = { pestId: pestId };
      let info = await this.ajax.getSubmit("/api/pest/get", paramObj);
      console.log(info);
      this.pest = info;
    },
    back() {
      this.$router.push("/home/pest");
    },
  },
  created() {
    //console.log(this.$route.query.pestId);
    this.pestId = this.$route.query.pestId;
    this.getPestInfo(this.pestId);
  },
};
</script>

<style>
h2 {
  margin-left: 380px;
}
.info {
  display: flex;
}
.left p {
  margin-bottom: 40px;
}
.right p{
  margin-bottom: 40px;
}
.right {
  margin-left: 200px;
}
.right span,
img {
  vertical-align: top;
  margin-right: 20px;
}
</style>